@extends('layout.index');
@section('title', '用户列表');
  @section('content')
     <div class="row">
               <div class="col-lg-12">
                   <h1 class="page-header">用户列表</h1>
               </div>
               <!-- /.col-lg-12 -->
           </div>
      <div class="col-lg-12">

  <div class="panel panel-default">
      <div class="panel-heading">
          用户详情
      </div>
      <!-- /.panel-heading -->
      <div class="panel-body">
          <div class="table-responsive">
            <form role="form" action="/admin/user/list" method="get">
            <!-- 搜索栏 -->
                <div class="col-lg-3.5 col-lg-offset-8">                           
                  <div class="form-group input-group">
                  <input type="text" class="form-control" id="sou" name="username">
                  <span class="input-group-btn">
                      <button class="btn btn-default"><i class="fa fa-search"></i>
                      </button>
                  </span>
                  </div>
                </div>
              </form>
              <table class="table table-hover">
                  <thead>
                      <tr>
                          <th>ID</th>
                          <th>用户名</th>
                          <th>头像</th>
                          <th>Email</th>
                          <th>Phone</th>
                          <th>是否激活</th>
                          <th>操作 </th>

                          
                      </tr>
                  </thead>
                  <tbody>
                    @foreach ($res as $k=>$v)
                      <tr>
                            <td class="qwe">{{$v->id}}</td>
                            <td>{{$v->username}}</td>
                            <td><img src="{{$v->pic}}" width="50px" height="50px"></td>
                            <td>{{$v->email}}</td>
                            <td>{{$v->phone}}</td>
                            <td>{{$v->status}}
                           
                            </td>
                            <td><a class="delete" href="#"><i class="fa fa-bitbucket"></i>删除</a>|
                                <a  href="/admin/user/edit?id={{$v->id}}"><i class="fa fa-vk"></i>修改</a>
                            </td>
                      </tr>
                     @endforeach

           
                    
                     
                      
                  </tbody>
              </table>
          </div>
          <div class="col-lg-4 col-lg-offset-4"> 
           {!! $res->render() !!}
           </div>
          <!-- /.table-responsive -->
      </div>
      <!-- /.panel-body -->
  </div>
  <!-- /.panel -->
</div>
@endsection

@section('script')
    <script type="text/javascript">
    //执行jquery/ajax请求
    // $.ajax();
    $('.delete').click(function(){
       var id = $(this).parents('tr').find('.qwe').html();
       var dele = $(this);
      // alert(id);
     $.get('/admin/user/delete',{id:id},function(data){
        if(data == 1){
            dele.parents('tr').remove();
        }else{
          alert('删除失败');
        }
     });
    });
    </script>
@endsection
